//
//  ReplacePwdController.m
//  DirectMember
//
//  Created by jzd on 2018/6/25.
//  Copyright © 2018年 宋佳. All rights reserved.
//

#import "ReplacePwdController.h"

@interface ReplacePwdController ()
@property (weak, nonatomic) IBOutlet UITextField *oldPwd;
@property (weak, nonatomic) IBOutlet UITextField *PwdFirst;
@property (weak, nonatomic) IBOutlet UITextField *PwdSecond;

@end

@implementation ReplacePwdController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.extendedLayoutIncludesOpaqueBars = NO;
    
    
    [self adjusteTextFiled];
    [self setTitleView];
    
    
}-(void)setTitleView{
    // 1.设置titleView
    UISegmentedControl *segMentControl = [[UISegmentedControl alloc] initWithItems:@[@"登录密码",@"交易密码"]];
    
    
    
    // 3.设置字体颜色
    [segMentControl setTitleTextAttributes:@{
                                             NSForegroundColorAttributeName : [UIColor whiteColor]
                                             } forState:UIControlStateNormal];
    [segMentControl setTitleTextAttributes:@{
                                             NSForegroundColorAttributeName : TITLECOLOR
                                             } forState:UIControlStateSelected];
    
    // 4.设置选中的索引
    segMentControl.selectedSegmentIndex = 0;
    
    // 5.设置前景色
    segMentControl.tintColor = [UIColor whiteColor];
    
    [segMentControl addTarget:self action:@selector(segmentValueChange:) forControlEvents:UIControlEventValueChanged];
    
    self.navigationItem.titleView = segMentControl;
}
-(void)segmentValueChange:(UISegmentedControl *)seg{
}
-(void)adjusteTextFiled{
    UIImage *im = [UIImage imageNamed:@"pwd"];
    UIImageView *iv = [[UIImageView alloc] initWithImage:im];
    UIView *lv = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 35)];//宽度根据需求进行设置，高度必须大于 textField 的高度
    iv.center = lv.center;
    [lv addSubview:iv];
    
    //设置 textField 的左侧视图
    //设置左侧视图的显示模式
    self.oldPwd.leftViewMode = UITextFieldViewModeAlways;
    self.oldPwd.leftView = lv;
    
    
    UIImage *img = [UIImage imageNamed:@"newPwd"];
    UIImageView *ivg = [[UIImageView alloc] initWithImage:img];
    UIView *lvg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 35)];//宽度根据需求进行设置，高度必须大于 textField 的高度
    ivg.center = lvg.center;
    [lvg addSubview:ivg];
    
    //设置 textField 的左侧视图
    //设置左侧视图的显示模式
    self.PwdFirst.leftViewMode = UITextFieldViewModeAlways;
    self.PwdFirst.leftView = lvg;
    
    self.PwdSecond.leftViewMode = UITextFieldViewModeAlways;
    UIView *VV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, 35)];
    VV.backgroundColor = [UIColor clearColor];
    self.PwdSecond.leftView = VV;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

- (IBAction)sureOnClick:(UIButton *)sender {
}

@end
